const Koa = require('koa');
const app = new Koa();
const io = require('socket.io')(10202);


app.use(async (ctx, next)=>{
    await next();
    ctx.response.type = 'text/html';
    ctx.response.body = '<h1>Hello, koa2!</h1>'
})

io.on('connect',socket=>{
    console.log('Socket emit hi to socket', socket);
    socket.emit('hi', 'everyone');
    socket.on('disconnect', ()=>{})
})

app.keys = ['im a newer server', 'i like turtle'];
app.listen(3000);
console.log('app started at port 3000...')
